/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.txweb;

import com.jspx.json.JSONObject;
import com.jspx.txweb.bundle.Bundle;
import com.jspx.txweb.table.ActionLog;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Map;
import java.util.List;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User:chenYuan (mail:39793751@qq.com)
 * Date: 2006-12-26
 * Time: 16:54:35
 */

public interface Action extends Serializable {
    //初始化,在调用 配置方法之前 或者 如果无配置方法在execute之前执行和标签运行前
    void initialize() throws Exception;

    //卸载数据,运行玩后释放空间
    void destroy();

    //执行
    String execute() throws Exception;

    //环境数据
    Map<String, Object> getEnv();

    void put(String key, Object obj);

    //信息存储
    List<String> getActionMessage();

    void addActionMessage(String msg);

    boolean hasActionMessage();

    //字段错误信息
    Map<String, String> getFieldInfo();

    void addFieldInfo(String keys, String msg);

    void addFieldInfo(Map<String, String> errors);

    boolean hasFieldInfo();

    //file 容器对象
    void setRequest(HttpServletRequest request);

    void setResponse(HttpServletResponse response);

    HttpServletRequest getRequest();

    HttpServletResponse getResponse();

    HttpSession getSession();

    String getEncode();

    String getLocaleName();

    //返回对象
    Object getResult();

    void setResult(Object value);

    void setTemplatePath(String templatePath);

    String getTemplatePath();

    String getTemplateFile();

    Object getBean(Class cla) throws Exception;

    //Object getSafeBean(Class cla) throws Exception;

    String getString(String name) throws Exception;

    String getString(String name, boolean checkSql) throws Exception;

    String getString(String name, String def, boolean checkSql);

    int getInt(String name) throws Exception;

    int getInt(String name, int def) throws Exception;

    String[] getArray(String name, boolean checkSql) throws Exception;

    int[] getIntArray(String name);

    int[] getIntArray(String name, int[] defArray);

    Integer[] getIntegerArray(String name);

    Integer[] getIntegerArray(String name, Integer[] defArray);

    Long[] getLongArray(String name) throws Exception;

    Long[] getLongArray(String name, Long[] defArray);

    double[] getDoubleArray(String name) throws Exception;

    Double[] getDoubleObjectArray(String name) throws Exception;

    float[] getFloatArray(String name) throws Exception;

    Float[] getFloatObjectArray(String name) throws Exception;

    double getDouble(String name, double def) throws Exception;


    long getLong(String name);

    long getLong(String name, long def) throws Exception;

    float getFloat(String name, float def) throws Exception;

    boolean getBoolean(String name) throws Exception;

    Date getDate(String name, String format) throws Exception;

    Date getDate(String name) throws Exception;

    String getPathLevel(int level);

    long getUrlNumber();

    String[] getParameterNames() throws Exception;

    String[] getAttributeNames() throws Exception;

    String getRemoteAddr();

    boolean isRepeatPost(String formHash);

    boolean isRepeatPost();

    String getFormHash();

    boolean isProcess();

    void setEnv(Map<String, Object> environment);

    boolean containsKey(String key);

    String getEnv(String keys);

    Long[] getLongJoinArray(String name1, String name2);

    String toQueryString(String name) throws Exception;

    String toQueryString(Map<String, String> param) throws Exception;

    //用户seesion
    Object getUserSession();

    //i18n
    Bundle getLanguage();

    Option getOption();

    Bundle getConfig();

    //日志对象
    void setActionLogTitle(String value);

    String getActionLogTitle();

    void setActionLogContent(Serializable value);

    Object getActionLogContent();

    ActionLog getActionLog();

    String getCookie(String name);

    String getActionResult();

    String getRootNamespace();

    void printError(String html, int status);

    void printError(JSONObject json, int status);

    void print(String html);

    void print(String html, int status);

    void print(JSONObject json);

    void print(JSONObject json, int status);

    void setActionResult(String actionResult);

    void setProcess(boolean process);

    boolean isMethodInvoked();

    boolean isMobileBrowser();

    boolean containsUserAgent(String str);

}